package com.example.bpmn.listener;

import org.camunda.bpm.engine.RuntimeService;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Component
@RequiredArgsConstructor
public class InventoryEventListener {
    
    private final RuntimeService runtimeService;
    
    @KafkaListener(topics = "inventory-events")
    public void handleInventoryEvent(String message) {
        log.info("收到库存事件: {}", message);
        
        // 触发等待库存的消息
        runtimeService.createMessageCorrelation("Message_InventoryAvailable")
            .correlateAll();
    }
} 